package velox.jcr.util;

import org.apache.commons.lang.StringUtils;

public class PathUtils {
	public static String getSuffix(String path) {
		return StringUtils.substringAfterLast(path, "/");
	}

	public static String getPrefix(String path) {
		return StringUtils.substringBeforeLast(path, "/");
	}
	
	public static String join(String... constituents) {
		StringBuilder builder = new StringBuilder();
		for (String s : constituents) {
			builder.append(s);
			if (builder.charAt(builder.length() - 1) != '/') {
				builder.append("/");
			}
		}
		if (builder.length() > 0) {
			builder.setLength(builder.length() - 1);
		}
		
		return builder.toString();
	}
}
